package com.hzit.hzb.core.controller.api;


import com.hzit.common.result.R;
import com.hzit.hzb.base.util.JwtUtils;
import com.hzit.hzb.core.pojo.entity.LendItemReturn;
import com.hzit.hzb.core.service.LendItemReturnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 标的出借回款记录表 前端控制器
 * </p>
 *
 * @author hbxfwf
 * @since 2024-08-27
 */
@RestController
@RequestMapping("/api/core/lendItemReturn")
public class LendItemReturnController {

	@Autowired
	private LendItemReturnService lendItemReturnService;

	/**
	 * 查询回款记录
	 * @param lendId
	 * @return
	 */
	@GetMapping("/auth/list/{lendId}")
	public R lendItemReturnList(@PathVariable("lendId") Long lendId, @RequestHeader("token") String token){
		Long userId = JwtUtils.getUserId(token);
		List<LendItemReturn> lendItemReturnList = lendItemReturnService.fetchLendItemReturnList(userId,lendId);
		return R.ok().data("list",lendItemReturnList);
	}
}

